<template>
    <div class="restContainer">
        <head-top head-title="密码修改" goBack="true"></head-top>
        <form class="restForm">
             <!-- <section class="input_container">
                <input type="text" placeholder="旧密码" name="oldPassWord" v-model="oldPassWord">
            </section> -->
            <section class="input_container">
                <input type="password" placeholder="请输入新密码" name="newPassWord" v-model="pw">
            </section>
            <section class="input_container">
                <input type="password" placeholder="请确认密码" name="confirmPassWord" v-model="pw2">
            </section>
        </form>
        <div class="login_container" @click="resetButton">确认修改</div>
    </div>
</template>

<script>
    import {Toast} from 'mint-ui'
	import headTop from '@/components/header/head'
	import {resetpw} from '@/api'
	import {mapMutations, mapState} from 'vuex'

    export default {
        data(){
            return {
				pw: '',
				pw2: '',
            }
        },
        components: {
            headTop,
        },
        computed:{
            ...mapState([
                'userInfo'
            ]),
		},
        methods: {
            ...mapMutations([
				'DIALOG_LOGIN',
			]),
			resetButton(){
				let para = {
					uid: this.userInfo.user_id,
					user_id: this.userInfo.user_id,
					pw: this.pw,
					pw2: this.pw2,
				}
				resetpw(para).then(res => {
					if(res.data){
						Toast(res.msg);
						this.pw = '';
						this.pw2 = '';
					}else{
						if(res.tologin){
							this.DIALOG_LOGIN();
							this.$router.push('/login');
						}else{
							Toast(res.msg);
						}
					}
				})
			}
        }
    }

</script>

<style lang="scss" scoped>
    @import 'src/style/mixin';

    .restContainer{
        padding-top: 1.95rem;
    }
    .restForm{
        background-color: #fff;
        margin-top: .6rem;
        .input_container{
            display: flex;
            justify-content: space-between;
            padding: .6rem .8rem;
            border-bottom: 1px solid #f1f1f1;
            input{
                @include sc(.7rem, #666);
            }
            button{
                @include sc(.65rem, #fff);
                font-family: Helvetica Neue,Tahoma,Arial;
                padding: .28rem .4rem;
                border: 1px;
                border-radius: 0.15rem;
            }
            .right_phone_number{
                background-color: #4cd964;
            }
        }
        .phone_number{
            padding: .3rem .8rem;
        }
        .captcha_code_container{
            height: 2.2rem;
            .img_change_img{
                display: flex;
                align-items: center;
                img{
                    @include wh(3.5rem, 1.5rem);
                    margin-right: .2rem;
                }
                .change_img{
                    display: flex;
                    flex-direction: 'column';
                    flex-wrap: wrap;
                    width: 2rem;
                    justify-content: center;
                    p{
                        @include sc(.55rem, #666);
                    }
                    p:nth-of-type(2){
                        color: #3b95e9;
                        margin-top: .2rem;
                    }
                }
            }
        }
    }
    .captcha_code_container{
        height: 2.2rem;
        .img_change_img{
            display: flex;
            align-items: center;
            img{
                @include wh(3.5rem, 1.5rem);
                margin-right: .2rem;
            }
            .change_img{
                display: flex;
                flex-direction: 'column';
                flex-wrap: wrap;
                width: 2rem;
                justify-content: center;
                p{
                    @include sc(.55rem, #666);
                }
                p:nth-of-type(2){
                    color: #3b95e9;
                    margin-top: .2rem;
                }
            }
        }
    }
    .login_container{
		width:96%;
		margin:1.3rem auto 0;
		line-height:1.5rem;
		@include borderRadius(1rem);
		text-align:center;
		background:#f86254;
		@include sc(.6rem,#fff);
    }
</style>
